package com.wsj.util.tool;

public class HtmlCreateStack 
{
	
    private int index = 0; //堆栈指针初始值为0
    private HtmlFileBean[] buffer = new HtmlFileBean[20]; //堆栈有20个字符的空间
    
	//连接数据库查询数据,获取页面字符串
	//压站
	 public synchronized void push(HtmlFileBean c)//加上互斥锁
	 { 
     	
         while(index == buffer.length)//堆栈已满，不能压栈
         {
              try
              {
                    this.wait(); //等待，直到有数据出栈
              }catch(InterruptedException e)
              {
               	
              }
         }
         this.notify(); //通知其它线程把数据出栈
         buffer[index] = c; //数据入栈
         index++; //指针向上移动
     }
	
	
	//出栈 生成静态页面
	 public synchronized HtmlFileBean pop()//加上互斥锁
	 { 
     	
         while(index ==0) //堆栈无数据，不能出栈
         { 
				try
				{
				   this.wait(); //等待其它线程把数据入栈
				}catch(InterruptedException e)
				{
					
				}
		   }
         this.notify(); //通知其它线程入栈
         index--; //指针向下移动
         return buffer[index];//数据出栈
    }
	

     


		public HtmlFileBean[] getBuffer() {
			return buffer;
		}


		public void setBuffer(HtmlFileBean[] buffer) {
			this.buffer = buffer;
		}


		public int getIndex() {
			return index;
		}


		public void setIndex(int index) {
			this.index = index;
		}

	
}
